<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 菱形  */

        for (let i = 1; i <= 3; i++) {
            // 打印空格
            for (let x = 1; x <= 3 - i; x++) {
                document.write("&nbsp;&nbsp;");
            }
            // 打印星号
            for (let y = 1; y <= 2 * i - 1; y++) {
                document.write(" *");
            }
            document.write("<br />");
        }

        for (let i = 1; i <= 2; i++) {
            // 打印空格
            for (let x = 1; x <= i; x++) {
                document.write("&nbsp;&nbsp;");
            }
            // 打印星号
            for (let y = 1; y <= 5 - 2 * i; y++) {
                document.write(" *");
            }
            document.write("<br />");
        }
    </script>
</body>

</html>